Page layout determination of an image undergoing optical character recognition

ABSTRACT

A method and system is provided for identifying a page layout of an image that includes textual regions. The textual regions are to undergo optical character recognition (OCR). The system includes an input component that receives an input image that includes words around which bounding boxes have been formed and a text identifying component that groups the words into a plurality of text regions. A reading line component groups words within each of the text regions into reading lines. A text region sorting component that sorts the text regions in accordance with their reading order.

RELATED APPLICATIONS

This Application is a Continuation of and claims benefit from U.S. patent application Ser. No. 12/721,949 that was filed on Mar. 11, 2010, and that is incorporated herein by reference in its entirety.

BACKGROUND

Optical character recognition (OCR) is a computer-based translation of an image of text into digital form as machine-editable text, generally in a standard encoding scheme. This process eliminates the need to manually type the document into the computer system. An OCR process typically begins by obtaining an electronic file of a physical document bearing the printed text message and scanning the document with a device such as an optical scanner. Such devices produce an electronic image of the original document. The output image is then supplied to a computer or other processing device and processes the image of the scanned document to differentiate between images and text and determine what letters are represented in the light and dark areas.

SUMMARY

Documents containing text may be arranged on a page with many different types of layouts. For instance, text may be arranged in multiple columns and images may be interspersed between different regions of text or even within a text column. In order to accurately perform the OCR process and retain the original page layout, it is important to determine this layout and the reading order of the text within that layout when the document is undergoing OCR.

In one implementation, a method is provided for identifying a page layout of an image that includes textual regions. The method begins by receiving an input image that includes words around which bounding boxes have been formed. The words are grouped into a plurality of text regions. The words within each of the text regions are then grouped into reading lines. The text regions are sorted in accordance with their reading order.

In one particular implementation, the words are grouped into a plurality of text regions by first identifying one or more white space regions which are located between the text regions.

This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows one illustrative example of a system for optical character recognition.

FIGS. 2 and 3 show examples of text regions on a page, denoted according to the reading order as text regions T1 and T2.

FIGS. 4-10 show illustrative examples of page layouts that may be determined by the methods, techniques and systems described herein.

FIG. 11 is a flowchart showing one example of a method for identifying a page layout of an image that includes textual regions.

FIG. 12 shows the coordinate system that is used to define a rectangle (either a white space rectangle or a text rectangle) on a document.

FIG. 13 shows an example of such a whitespace candidate seed.

FIG. 14 illustrates the process of merging white space seeds by expanding a seed to cover the image to its right.

FIG. 15 shows the process of expanding and shrinking the white space rectangles.

FIG. 16 is an example of a page layout used to illustrate one method for identifying text regions.

FIG. 17 is an example of a page layout used to illustrate another method for identifying text regions.

FIG. 18 shows an example of a page layout having multiple columns and headers and footers.

FIG. 19 shows one example of an image processing system that may perform a method for identifying a page layout of an image that includes textual regions.

DETAILED DESCRIPTION

FIG. 1 shows one illustrative example of a system 5 for optical character recognition (OCR) which includes a data capture arrangement (e.g., a scanner 10) that generates an image of a document 15. The scanner 10 may be an imager-based scanner which utilizes a charge-coupled device as an image sensor to generate the image. The scanner 10 processes the image to generate input data, and transmits the input data to a processing arrangement (e.g., an OCR engine 20) for character recognition within the image. In this particular example the OCR engine 20 is incorporated into the scanner 10. In other examples, however, the OCR engine 20 may be a separate unit such as stand-alone unit or a unit that is incorporated into another device such as a PC, server, or the like.

The accuracy of an OCR process can be significantly improved if the correct page layout (e.g., the geometry of text regions and lines within text regions) and the reading order of the document can be determined. In addition to overall recognition accuracy, the successful detection of these layout elements has a significant impact on retention of the original layout in the resulting output document. As detailed below, a method is presented for correctly determining the reading order of text regions and the grouping of words into text regions.

A text region may be roughly defined as the maximum area, typically a rectangle, that contains all word bounding boxes that can be grouped in textual lines, which, when sorted based on their vertical position, reflect the reading order in the aforementioned rectangle. The reading order in a document is given by the order of the text regions, and by the order of lines inside each text region. FIGS. 2 and 3 show examples of text regions on a page, denoted according to the reading order as text regions T1 and T2. The document in FIG. 2 also includes a non-textual image 11.

A white space rectangle may be defined as the maximal inter-word rectangle which does not intersect any word bounding box, which is a rectangle determining the portion of the image that contains the given word.

The process described below groups words into lines based on their bounding boxes. More specifically, words are grouped into lines based on the distance between them, their relative vertical position and the height of their bounding box. The lines are then grouped into text regions, and the reading order within a given region is determined by the vertical order of the lines. The reading order of the document is given by the sequence of text regions which corresponds to the natural flow of text.

The process can be applied to page layouts that are both simple and complex. Examples of such page layouts are shown in FIGS. 4-10.

This process can be summarized by the sequence of steps illustrated in the flowchart shown in FIG. 11. First, in step 110, the text regions are detected. Within each text region words are grouped into reading lines in step 120. The text regions are refined in step 130 and sorted according to reading order in step 140.

Text Region Detection

Text detection is based on the spacing between words. It takes advantage of the fact that in general inter-column spacings are wider than inter-word spacings and that the text regions exhibit some regularities, such as alignment, for example. In order to detect the text regions on a document, the white space rectangles are first computed, which will form the inter-region spaces.

The coordinates that will be used to define a rectangle (either a white space rectangle or a text rectangle) on a document are shown in FIG. 12. The origin will be assumed to be located at the top right edge of the document. Of course, these coordinates are used for purposes of illustration. In general, any suitable coordinate system may be employed.

The process of computing white space rectangles begins by selecting white space seeds, which are candidate interspace regions. To qualify as a seed, an inter-word space has to have a width greater than some threshold while also being able to be expanded in height. Seeds are identified by sorting words (from left-right and top-bottom). Then, a whitespace candidate seed is built between two word bounding boxes, w^(i) and w^(j), whose vertical projections overlap:

whiteRect_(left)=min(w _(right) ^(i) , w _(right) ^(j))

whiteRect_(right)=max(w _(left) ^(i) , w _(left) ^(j))

whiteRect_(top)=min(w _(top) ^(i) , w _(top) ^(j)) whiteRect_(bottom)=max(w _(bottom) ^(i) , w _(bottom) ^(j))

Where w_(right) ^(i) is the coordinate of the rightmost border of word bounding box i. The other borders of the bounding boxes are defined in a similar manner. An example of such a whitespace candidate seed wR is shown in FIG. 13.

Finally, after they have been determined, whitespace candidates seeds that overlap with word bounding boxes are removed.

An alternate way of computing the whitespace candidate seeds is to find, for each word bounding box, the nearest neighbor bounding box to its right (which is also vertically overlapping) and compute the white space as the space between these two words. The resulting whitespace rectangle is guaranteed not to intersect any other word bounding box, since it has been chosen as the space between one word bounding box and the nearest word bounding box to the right.

Once a set of whitespace candidate seeds is obtained, each one is expanded vertically expanded upwards and downwards by a configurable amount. That is, the coordinates of the top and bottom borders of each candidate seed are changed as follows:

whiteRect_(top)=whiteRect_(top)−α· height (here

whiteRect_(bottom)=whiteRect_(bottom)+α· height

Where α is a configurable constant and height is the average word bounding box height, which has been precomputed as a page property.

The expanded whitespace candidate seeds are filtered, and only those that do not intersect any word bounding boxes are kept as white space seeds. These white space seeds then undergo another expansion process.

First, whitespace seeds are merged if they have any overlapping areas. Next, the seeds are expanded horizontally to cover any images, provided that the resulting rectangular seed does not also overlap any word bounding boxes. As an example, FIG. 14 shows a white space seed that can be expanded to cover the image to its right.

The resulting whitespace rectangles are once again vertically expanded upwards and downwards, while also shrinking them horizontally if they overlap with any word bounding boxes. This expansion and shrinking process continues until the resulting whitespace rectangle has a width that falls below some configurable threshold. In addition, if two whitespace rectangles start intersecting one another as a result of the expansion process they are merged together.

The vertical expansion and horizontal shrinking of the whitespace rectangles needed), proceed in accordance with the following formulas:

Shrink:

rect_(left)=max(wb _(right) ^(i)), wb ^(i) overlaps vertically with rect, and wb _(right) ^(i)<rect_(right)

rect_(right)=min(wb _(left) ^(i)), wb ^(i) overlaps vertically with rect, and wb _(left) ^(i)<rect_(left)

Expand:

rect_(top)=max(wb _(bottom) ^(i)), wb ^(i) overlaps horizontally with rect, and wb _(bottom) ^(i)<rect_(top)

rect_(bottom)=min(wb _(top) ^(i)), wb ^(i) overlaps horizontally with rect, and wb _(top) ^(i)>rect_(bottom)

Where wb^(i) represents the word bounding boxes and rect is the whitespace rectangle being expanded.

If there are no word bounding boxes horizontally overlapping (above or below) with the white space rectangle, the rectangle is expanded up to the minimum word bounding box top and the maximum word bounding box bottom, which may be precomputed as page statistics. The rectangles are expanded, if the resulting rectangle is wider than some threshold, which also may be expressed as a function of precomputed page statistics. If expanding one rectangle would result in a rectangle which is not sufficiently wide, the expansion is cancelled, and the rectangle is kept with its coordinates prior to the expansion.

The process of expanding and shrinking the white space rectangles is illustrated in FIG. 15. Starting with the whitespace rectangle WR0, which overlaps some word bounding boxes, it is shrunk so that it can be further expanded vertically until it overlaps with another word bounding box. The resulting rectangle is denoted WR1. Then, since it is possible to shrink the rectangle once again, it is further expanded from WR1 to WR2. After this step, WR2 cannot be vertically expanded upward anymore (since its width would fall below some threshold value, relative to the average word height). As a consequence, the coordinate of the top border of WR2 will be chosen to be equal to the value of the coordinate of the bottom border of the word bounding box immediately above it (which in the example of FIG. 15 is the word “during”).

Any resulting white space rectangles that overlap are once again merged until there are no more overlapping white space rectangles. The remaining white space rectangles are reduced so that their top borders match the top of the topmost word bounding box with which they vertically overlap. Likewise, the bottom borders of the whitespace rectangles are reduced so that they match the bottom of the bottommost word bounding boxes with which they vertically overlap.

Next, the whitespace rectangles are ranked in such a way that reflects the likelihood that they actually correspond to inter-region spaces between different text regions. Only those whitespace rectangles that receive a ranking or score above a threshold value will be maintained as inter-space regions. For each rectangle, two values are computed. One value is computed as the number of word bounding boxes that vertically overlap with the whitespace rectangle, positioned to the right of the whitespace rectangle, and which are closer than some threshold to the whitespace rectangle.

The other value is computed as the number of word bounding boxes vertically overlapping with the whitespace rectangle, positioned to the left of the whitespace rectangle, and which are closer than some threshold to the whitespace rectangle. In addition, however, this value only includes word bounding boxes that are wider than some minimum width, thereby eliminating from the value such items as bullets, list numbers and the like. The ranking or score of a white space rectangle is computed as the sum of its right and left values.

The whitespace rectangles are filtered by their score or ranking. In the case of overlapping rectangles with equal scores, the wider whitespace rectangle will be retained. The final set of whitespace rectangles is once again filtered by score so that only the higher ranked rectangles (expressed as a percentage of all the rectangles or as a numerical score) are retained.

Once the white space rectangles have been determined in the manner described above, the text regions can be determined in one of two ways that will be described below.

The first method to identify text regions will be described in connection with the example in FIG. 16. The method begins by selecting the entire page as a candidate text region. Next, the candidate text region is examined to see if it contains any white space rectangles. If not, then the entire page represents a single text region. Alternatively, if the candidate text region contains one or more whitespace rectangles (three are present in FIG. 16), the largest of them is selected. The candidate text region is then sliced into separate text regions located above and below and to the left and right of the selected whitespace rectangle In FIG. 16, the whitespace rectangle W is selected and the candidate text region (i.e. the full page) is divided into separate text regions R2 and R3, which are to the left and right, respectively, of whitespace rectangle W. It is also divided into text region R1 located above the whitespace rectangle W. In this example there is no text region below the whitespace rectangle W. Once again, each of the candidate text regions R1, R2 and R3 are examined to determine if they contain any whitespace rectangles. If not, then the candidate text region is identified as an actual text region. This is the case for text regions R2 and R3 in FIG. 16. If the candidate text region does contain one or more whitespace rectangles, the largest one is selected and the text region in which it is located is once again sliced in the manner described above. In the example of FIG. 16 the text region R1 contains two whitespace rectangles. This process continues until all the text regions which do not contain any whitespace regions have been identified.

The second method to identify text regions can be described by the following algorithm, which is illustrated in connection with the example in FIG. 17.

First, all the whitespace rectangles are sorted by their left coordinate.

An initial region R is then defined, which is bounded by the page margins P {Pleft, Ptop, Pright, Pbottom}.

Next, the region R is added to a temporary region set T and the temporary region count is set to 1.

For each whitespace rectangle W:

For each temporary region R1;

If R1 intersects a whitespace rectangle W, the excess regions above and below it are computed as follows:

If R1 intersects a whitespace rectangle W, the excess regions above and below it are computed as follows:      diffUp = max(0, R1_(top) − W_(top))     diffDown = max(0, R1_(bottom) − W_(bottom))   If (diffUp > 0)    Add RT{R1left,R1top, R1right, Wtop} to T;   If (diffDown > 0)    Add RB{R1left,Wbottom, R1right, R1bottom} to T;   Add R2 {R1left, R1top,Wleft, R1bottom} to the finished   regions set, F;   Add R3{Wright, Wtop, Pright, Wbottom}to the set of   temporary regions; this   will be a region to the right of the white space rectangle,   to continue building final   text regions to the right;   Let RT1 be: {RTleft, RTtop, Wright, Wtop},   If RT1 does not contain any word bounding boxes,   R2 is expanded to the top, and   RT is reduced to the right of W;  End for each temporary region; End for each whitespace rectangle.

Finally, this second method of identifying text regions ends by attempting to merge text regions which are adjacent (R2top=R1bottom) and are aligned on the left coordinate (R1left=R2left).

Group Words into Reading Lines

After the set of text regions have been identified, the reading lines within each text region are created. This is accomplished by first grouping the words into three categories based on their height relative to an average height of the words in the text region. Line height is computed as the difference between the maximum of the bottom coordinates of the word bounding boxes and the minimum of their top coordinates. Next, the words assigned to the average category are arranged into a set of reading lines. If any particular word does not vertically overlap with any other line, a reading line is created which only contains this word. After the reading lines have been created, the words assigned to the small category are added to the existing reading lines (The small category generally includes items such as punctuation, footnote marks, etc). Finally, the words assigned to the tall category are added to existing set of reading lines. If the order were reversed so that tall words were first used to create the reading lines, overlapping merged lines would likely be created.

Refinement of Text Regions

After the reading lines have been established, various post processing may be performed. For instance, the text regions may be refined to improve reading order and to correct the order of the lines in some special situations. This may be accomplished by merging broken regions, which are regions that overlap horizontally, have a small distance between them, and when merged, yield a rectangle that does not overlap other text regions. The merged region will be bounded by the smallest rectangle that contains the regions being merged.

Another post-processing step may be performed for pages with multiple columns if they include headers or footers having a width less than the column width or if they have gaps matching the inter column space. FIG. 18 shows an example of such a page layout. In this situation one additional step may be performed to break the first line of a text region if the first line appears to have different features compared to the statistics (e.g., text height, inter-line spacing) for the text region

The page layout shown in FIG. 18 represents a common example in which the reading order may be miscomputed as a result of merging the header and the page number with the other text regions. In this example, features such as the median of the line interspace within the text region and the height and character stroke width may be used to determine whether to break the first and/or last line or lines from the remainder of the text region.

Sorting of Text Regions into Reading Order

Finally, the text regions which have been identified and refined, if necessary, are sorted using a simple, but effective ordering rule. Given two text regions R1, R2:

${{compare}\left( {R_{1},R_{2}} \right)} = \left\{ \begin{matrix} {{{sgn}\left( {R_{1\mspace{14mu} {left}} - R_{2\mspace{14mu} {left}}} \right)},} & {{if}\mspace{14mu} R_{1}\mspace{14mu} {and}\mspace{14mu} R_{2}\mspace{14mu} {overlap}\mspace{14mu} {vertically}} \\ {{{sgn}\left( {R_{1\mspace{14mu} {top}} - R_{2\mspace{14mu} {top}}} \right)},} & {otherwise} \end{matrix} \right.$

where the sgn function is the standard sign function, defined as follows:

${{sgn}(x)} = \left\{ \begin{matrix} {{- 1},} & {{{if}\mspace{14mu} x} < 0} \\ {1,} & {{{if}\mspace{14mu} x} > 0} \\ {0,} & {{{if}\mspace{14mu} x} = 0.} \end{matrix} \right.$

Assuming the origin of the coordinate system is the upper left corner of the page, this comparison step returns 0 if the regions are identical, −1 if R1 should be appear before R2 in the reading order, and 1 otherwise.

In other words, the left-most borders of text regions which vertically overlap with one another are compared. The regions are then assigned a reading order such that a text region with a left-most border closer to a left edge of the page is assigned an earlier place in the reading order than a text region with a left-most border more distant from the left edge of the page. In addition, the top-most borders of text regions that do not vertically overlap with one another are compared. Arcading order is assigned to these text regions such that a text region with a top-most border closer to a top edge of the page is assigned an earlier place in the reading order than a text region with a top-most border more distant from the top edge of the page.

Because of the manner in which the text regions have been determined, the reading lines inside each text region are already sorted according to the reading order (from top to bottom).

FIG. 19 shows one example of an image processing system 300 that may perform the method for identifying a page layout of an image that includes textual regions. The system 300 includes an input component 310 that receives an input image that includes words around which bounding boxes have been formed. A text identifying component 320 groups the words into a plurality of text regions. The text identifying component includes a white space component 322 for determining the white space rectangles and a text region formation component 324 for forming the text regions using the white space rectangles in the manner described above. The system 300 also includes a reading line component 330 that groups words within each of the text regions into reading lines and a text region sorting component 340 that sorts the text regions in accordance with their reading order.

As used in this application, the terms “component,” “module,” “system,” “apparatus,” “interface,” or the like are generally intended to refer to a computer-related entity, either hardware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a controller and the controller can be a component. One or more components may reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between two or more computers.

Furthermore, the claimed subject matter may be implemented as a method, apparatus, or article of manufacture using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to implement the disclosed subject matter. The term “article of manufacture” as used herein is intended to encompass a computer program accessible from any computer-readable device, carrier, or media. For example, computer readable media can include but are not limited to magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips . . . ), optical disks (e.g., compact disk (CD), digital versatile disk (DVD) . . . ), smart cards, and flash memory devices (e.g., card, stick, key drive . . . ). Of course, those skilled in the art will recognize many modifications may be made to this configuration without departing from the scope or spirit of the claimed subject matter.

Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. 

1. A method performed on a computing device, the method comprising: identifying whitespace regions in an image; grouping words in the image into first text regions; dividing any of the first text regions that include at least one of the identified whitespace regions until second text regions are established that do not include any of the identified whitespace regions, where the dividing results in final text regions that include any first text regions that do not include any of the identified whitespace regions and any second text regions; and sorting the final text regions in accordance with their reading order.
 2. The method of claim 1 where a page image comprises the words, and where each of the words is contained in a bounding box.
 3. The method of claim 2 where the whitespace regions include any images positioned among the words while not overlapping any of the bounding boxes.
 4. The method of claim 1 where none of the identified whitespace regions overlap each other.
 5. The method of claim 1 further comprising creating reading lines within each of the final text regions.
 6. The method of claim 1 where space between columns of the words is encompassed by the whitespace regions.
 7. The method of claim 1 where the reading order comprises a natural flow of text of the sorted text regions.
 8. A system comprising a computing device and at least one program nodule that are together configured for performing actions comprising: identifying whitespace regions in an image; grouping words in the image into first text regions; dividing any of the first text regions that include at least one of the identified whitespace regions until second text regions are established that do not include any of the identified whitespace regions, where the dividing results in final text regions that include any first text regions that do not include any of the identified whitespace regions and any second text regions; and sorting the final text regions in accordance with their reading order.
 9. The system of claim 8 where a page image comprises the words, and where each of the words is contained in a bounding box.
 10. The system of claim 9 where the whitespace regions include any images positioned among the words while not overlapping any of the bounding boxes.
 11. The system of claim 8 where none of the identified whitespace regions overlap each other.
 12. The system of claim 8, the actions further comprising creating reading lines within each of the final text regions.
 13. The system of claim 8 where space between columns of the words is encompassed by the whitespace regions.
 14. The system of claim 8 where the reading order comprises a natural flow of text of the sorted text regions.
 15. At least one computer storage device storing software that, when executed by a computing device, causes the computing device to perform actions comprising: identifying whitespace regions in an image; grouping words in the image into first text regions; dividing any of the first text regions that include at least one of the identified whitespace regions until second text regions are established that do not include any of the identified whitespace regions, where the dividing results in final text regions that include any first text regions that do not include any of the identified whitespace regions and any second text regions; and sorting the final text regions in accordance with their reading order.
 16. The at least one computer storage device of claim 15 where a page image comprises the words, where each of the words is contained in a bounding box, and where the whitespace regions include any images positioned among the words while not overlapping any of the bounding boxes.
 17. The at least one computer storage device of claim 15 where none of the identified whitespace regions overlap each other.
 18. The at least one computer storage device of claim 15, the actions further comprising creating reading lines within each of the final text regions.
 19. The at least one computer storage device of claim 15 where space between columns of the words is encompassed by the whitespace regions.
 20. The at least one computer storage device of claim 15 where the reading order comprises a natural flow of text of the sorted text regions. 